<template>
  <div class="profile-container">
    <!-- 状态栏 -->
    <div class="status-bar">
      <span class="time">12:30</span>
      <div class="status-icons">
        <span class="signal">📶</span>
        <span class="wifi">📶</span>
        <span class="battery">🔋</span>
      </div>
    </div>

    <!-- 头部 -->
    <div class="header">
      <div class="back-btn" @click="goBack">
        <span>←</span>
      </div>
      <h1 class="page-title">我的</h1>
      <div class="header-right">
        <span class="settings-icon">⚙️</span>
      </div>
    </div>

    <!-- 用户信息卡片 -->
    <div class="user-card">
      <div class="user-avatar">
        <img :src="userStore.userInfo?.Avatar || '/default-avatar.png'" alt="头像" />
      </div>
      <div class="user-info">
        <h2 class="username">{{ userStore.userInfo?.Username || '用户' }}</h2>
        <p class="user-phone">{{ userStore.userInfo?.Phone || '' }}</p>
        <p class="user-email">{{ userStore.userInfo?.Email || '' }}</p>
      </div>
      <div class="edit-btn" @click="showFeatureNotReady">
        <span>✏️</span>
      </div>
    </div>

    <!-- 功能菜单 -->
    <div class="menu-section">
      <div class="menu-group">
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">📋</div>
          <div class="menu-text">我的预约</div>
          <div class="menu-arrow">→</div>
        </div>
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">📊</div>
          <div class="menu-text">检查报告</div>
          <div class="menu-arrow">→</div>
        </div>
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">💊</div>
          <div class="menu-text">用药记录</div>
          <div class="menu-arrow">→</div>
        </div>
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">🏥</div>
          <div class="menu-text">就诊记录</div>
          <div class="menu-arrow">→</div>
        </div>
      </div>

      <div class="menu-group">
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">🔒</div>
          <div class="menu-text">隐私设置</div>
          <div class="menu-arrow">→</div>
        </div>
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">🔔</div>
          <div class="menu-text">消息通知</div>
          <div class="menu-arrow">→</div>
        </div>
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">❓</div>
          <div class="menu-text">帮助中心</div>
          <div class="menu-arrow">→</div>
        </div>
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">📞</div>
          <div class="menu-text">联系客服</div>
          <div class="menu-arrow">→</div>
        </div>
      </div>

      <div class="menu-group">
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">ℹ️</div>
          <div class="menu-text">关于我们</div>
          <div class="menu-arrow">→</div>
        </div>
        <div class="menu-item" @click="showFeatureNotReady">
          <div class="menu-icon">📝</div>
          <div class="menu-text">意见反馈</div>
          <div class="menu-arrow">→</div>
        </div>
      </div>
    </div>

    <!-- 退出登录按钮 -->
    <div class="logout-section">
      <button class="logout-btn" @click="handleLogout">
        退出登录
      </button>
    </div>

    <!-- 版本信息 -->
    <div class="version-info">
      <p>智慧医院平台 v1.0.0</p>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
import { showToast, showConfirmDialog } from 'vant'

const router = useRouter()
const userStore = useUserStore()

const goBack = () => {
  router.back()
}

const showFeatureNotReady = () => {
  showToast({
    message: '功能开发中，敬请期待！',
    position: 'middle',
    duration: 2000,
    forbidClick: true
  })
}

const handleLogout = () => {
  showConfirmDialog({
    title: '确认退出',
    message: '确定要退出登录吗？',
    confirmButtonText: '退出',
    cancelButtonText: '取消'
  }).then(() => {
    // 清除用户信息
    userStore.clearUserInfo()
    
    // 显示退出成功提示
    showToast({
      message: '已退出登录',
      position: 'middle',
      duration: 1500,
      forbidClick: true
    })
    
    // 跳转到登录页
    setTimeout(() => {
      router.push('/login')
    }, 1500)
  }).catch(() => {
    // 用户取消退出
  })
}
</script>

<style scoped>
.profile-container {
  min-height: 100vh;
  background: #f8f9fa;
  position: relative;
}

/* 状态栏 */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: white;
  font-size: 14px;
  color: #333;
}

.status-icons {
  display: flex;
  gap: 5px;
}

/* 头部 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: white;
  border-bottom: 1px solid #eee;
}

.back-btn {
  font-size: 20px;
  cursor: pointer;
  color: #333;
}

.page-title {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin: 0;
}

.header-right {
  font-size: 20px;
  cursor: pointer;
}

/* 用户信息卡片 */
.user-card {
  background: white;
  margin: 20px;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  flex: 1;
}

.username {
  margin: 0 0 5px 0;
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.user-phone, .user-email {
  margin: 0 0 3px 0;
  font-size: 14px;
  color: #666;
}

.edit-btn {
  font-size: 20px;
  cursor: pointer;
  color: #666;
}

/* 功能菜单 */
.menu-section {
  margin: 0 20px;
}

.menu-group {
  background: white;
  border-radius: 12px;
  margin-bottom: 15px;
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background-color: #f8f9fa;
}

.menu-icon {
  font-size: 20px;
  margin-right: 15px;
  width: 24px;
  text-align: center;
}

.menu-text {
  flex: 1;
  font-size: 16px;
  color: #333;
}

.menu-arrow {
  font-size: 16px;
  color: #ccc;
}

/* 退出登录按钮 */
.logout-section {
  margin: 20px;
}

.logout-btn {
  width: 100%;
  padding: 15px;
  background: #ff4757;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.logout-btn:hover {
  background: #ff3742;
}

/* 版本信息 */
.version-info {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 12px;
}

.version-info p {
  margin: 0;
}

/* 自定义Toast样式 */
:deep(.van-toast) {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
}

:deep(.van-toast--middle) {
  top: 50%;
  transform: translateY(-50%);
}

/* 自定义确认对话框样式 */
:deep(.van-dialog) {
  border-radius: 12px;
}

:deep(.van-dialog__header) {
  padding: 20px 20px 10px;
  font-size: 18px;
  font-weight: bold;
}

:deep(.van-dialog__content) {
  padding: 10px 20px 20px;
  font-size: 16px;
  color: #666;
}

:deep(.van-dialog__footer) {
  padding: 0 20px 20px;
}

:deep(.van-button) {
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
}

:deep(.van-button--default) {
  color: #666;
  border-color: #ddd;
}

:deep(.van-button--danger) {
  background: #ff4757;
  border-color: #ff4757;
  color: white;
}
</style> 